<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">		
 <title><? echo $title ?></title>
<? require_once("lib.php"); ?>
</head>
<body>
<div class="content-box"><!-- Start Content Box -->
  <div class="content-box-header">
      <h3><? echo $title ?></h3>
      <div class="clear"></div>
  </div> <!-- End .content-box-header -->
  <div class="content-box-content">
<?
  switch ($do) {
    case "add":
    	add();
    	break;
	case "update":
		update($info);
		break;
	case "delete":
		delete($id);
		break;
    default:	
		show_info($info);
  }
 ?>
<? function show_box($row, $iseditmode, $isadd=false){ 
	global $id, $h, $cateid, $url, $title, $userid, $product, $lang, $code_array;
	$tem=$product->get_row($cateid);
	$status_array=$code_array['review_status'];
	$sku=$tem['sku'];
	$product_name=$product->get_name($id,$lang);
	$customer_id=0; if(isset($row['customer_id'])) $customer_id=$row['customer_id'];
	$time=date('Y-m-d H:i:s'); if(isset($row['created_time'])) $time=$row['created_time'];
	$rate=array(1=>array('id'=>1,'name'=>'1'),2=>array('id'=>2,'name'=>'2'),3=>array('id'=>3,'name'=>'3'),4=>array('id'=>4,'name'=>'4'),5=>array('id'=>5,'name'=>'5'));
	?>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox">
	  <tr class="th"><td class="thtitle" width="148" align="right"><? echo $title ?></td>
	  	<td><? echo $h->hidden('id', $row["id"]); ?>
	  		<? echo $h->hidden('customer_id', $customer_id); ?>
	  		<? echo $h->hidden('cateid', $cateid); ?></td></tr>
	  <? if($isadd){ ?>
	  <tr><td class="l"><?=ROOT_CUSTOMER_NAME?></td><td><? echo $h->text('customer_name',$row['customer_name'],'gs') ?></td></tr>
	  <tr><td class="l"><?=ROOT_PRODUCT?></td><td><? echo $product_name." (".$sku.")" ?></td></tr>
	  <tr><td class="l"><?=ROOT_COMMENT?></td><td><? echo $h->textarea('content', $row["content"], 24, 4, 'g', '') ?></td></tr>
	  <tr><td class="l"><?=ROOT_RATING?></td><td><? echo $h->select('rating',$row['rating'],$rate,'id','name','gs') ?></div></td></tr>
	  <tr><td class="l"><?=ROOT_REVIEW_TIME?></td><td><? echo $h->text('created_time',$time,'gs') ?></td></tr>
	  <? } else { ?>
	  <tr><td class="l"><?=ROOT_CUSTOMER_NAME?></td><td><? echo $row['customer_name'] ?></td></tr>
	  <tr><td class="l"><?=ROOT_PRODUCT?></td><td><? echo $product_name." (".$sku.")" ?></td></tr>
	  <tr><td class="l"><?=ROOT_COMMENT?></td><td><? echo $row["content"] ?></td></tr>
	  <tr><td class="l"><?=ROOT_RATING?></td><td><? echo "<div class=\"rating2 star".$row['rating']."\"></div>"; ?></div></td></tr>
	  <tr><td class="l"><?=ROOT_REVIEW_TIME?></td><td><? echo $time ?></td></tr>
	  <? } ?>
	  <tr><td class="l"><?=ROOT_STATUS?></td><td><? echo $h->select('review_status',$row['review_status'],$status_array,'id','name_'.$lang,'gs') ?></div></td></tr>
	  <tr><td class="l">&nbsp;</td><td><br><? echo $h->submit('save', '&nbsp; '.ROOT_SAVE.' &nbsp;', $iseditmode?'':'hide') ?>&nbsp;&nbsp;<a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a><br><br></td></tr>
	</table>
<? } ?>
<? function show_boxes($result){
	global $page, $pages, $cateid, $s, $product, $url, $h, $userid, $lang, $code_array;
	$status_array=$code_array['review_status'];
	$str='<table width="99%" cellspacing="0" class="mlist"><tr class="th"><td><strong>#</strong></td><td><strong>'.ROOT_COMMENT.'</strong></td><td><strong>'.ROOT_CUSTOMER.'</strong></td><td><strong>'.ROOT_PRODUCT.'</strong></td><td><strong>'.ROOT_RATING.'</strong></td><td><strong>'.ROOT_STATUS.'</strong></td><td><strong>'.ROOT_REVIEW_TIME.'</strong></td><td><strong><a class="nada" href="'.$url.'.php?do=add&cid='.$cateid.'">[ '.ROOT_ADD.' ]</a></strong></td></tr>';
	$count=1;
	foreach($result as $row)
	{
		$id=decode($row['id']);
		$tem=$product->get_row($row['product_id']);
		$sku=$tem['sku'];
		$status=$status_array[$row['review_status']]['name_'.$lang];
		$product_name=$product->get_name($id,$lang);
  		$str.="<tr><td>".$id.".</td><td><a href=\"".$url.".php?do=update&cid=".$row['product_id']."&id=".$id."\">".substr(d($row['content']),0,36)."...</a></td><td>".$row['customer_name']."</td><td>".$product_name." (".$sku.")"."</td><td><div class=\"rating2 star".$row['rating']."\"></div></td><td>".$status."</td><td>".$row['created_time']."</td><td><a href=\"".$url.".php?do=update&cid=".$row['product_id']."&id=".$id."\">".ROOT_UPDATE."</a> | <a href=\"$url.php?cid=".$row['product_id']."&page=".$page."&do=delete&id=".decode($row['id'])."\" onClick=\"return delc();\">".ROOT_DELETE."</a></td></tr>";
		$count++;
	}
	$str.= "</table>";
	echo $str;
	if($count==1) echo "<br>".ROOT_NO_DATA."!";
	echo echo_page($page, $pages, $url.'-'.$cateid.'-p');
 } ?>
<br class="clear" />
<p class="red"><?=ROOT_APPROVAL_PRIOR_DISPLAY?></p>
	</div> <!-- End .content-box-content -->
         <br class="clear" />
</div><!-- End .content-box -->
</body>
</html>